package com.cow;

import java.util.TimeZone;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.remoting.caucho.HessianServiceExporter;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import com.cow.support.remote.AuthRemoteService;
import com.cow.support.remote.IAuthRemoteService;

/**
 * Spring Boot 启动类
 * 
 * @author yangsj 
 */

@SpringBootApplication
@ServletComponentScan
@EnableRedisHttpSession
@EnableTransactionManagement 
@EnableDiscoveryClient
public class Application {
	@Autowired 
	AuthRemoteService authRemoteService;
	public static void main(String[] args) {	
		init();
		SpringApplication.run(Application.class, args);		
	}

	private static void init(){ 
		//设置时区
	    System.setProperty("user.timezone","Asia/Shanghai"); 
	    TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
	}
	
	//发布服务
    @Bean(name = "/remote/authRemoteService")
    public HessianServiceExporter accountService() {
        HessianServiceExporter exporter = new HessianServiceExporter();
        exporter.setServiceInterface(IAuthRemoteService.class);
        exporter.setService(authRemoteService);        
        return exporter;
    }
	
}
